package com.example.movies.Util;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.view.View;
import android.view.Window;
import android.widget.Toast;

public class Base_Util {
    public static void Setimmersion(Window win)
    {
        //设置沉浸模式
        if (Build.VERSION.SDK_INT >= 21) {
            View decorView = win.getDecorView();
            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            decorView.setSystemUiVisibility(option);
            win.setStatusBarColor(Color.TRANSPARENT);
//            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
            //设置底部栏透明
//            win.setNavigationBarColor(Color.TRANSPARENT);
        }
    }
    //检查网络状态
    public static boolean isNetworkConnected(Context context) {
        if (context != null) {
            ConnectivityManager mConnectivityManager = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
            if (mNetworkInfo != null) {
                return mNetworkInfo.isAvailable();
            }
        }
        return false;
    }
    //显示toast
    public static void showmeg(final String text, final Activity activity)
    {
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(activity, text, Toast.LENGTH_SHORT).show();
            }
        });
    }
}
